package com.woody.led;

import java.awt.Component;
import java.awt.GridLayout;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;

/**
 * http://www.java3z.com/cwbwebhome/article/article8/81105.html
 * 
 * http://www.java2s.com/Tutorial/Java/0240__Swing/Usesmanyfeatures.htm
 * 
 * @author Stan
 * 
 */
public class ComplexCellRenderer extends JPanel implements ListCellRenderer {

	private static final long serialVersionUID = 8207067868313413746L;

	private JLabel iconLabel;

	private JLabel titleLabel;

	private ImageIcon icon;

	// private JLabel descriptionLabel;

	public ComplexCellRenderer() {
		super();
		URL url = ComplexCellRenderer.class.getResource("/images/Categories.png");
		icon = new ImageIcon(url);
		
		iconLabel = new JLabel();
		titleLabel = new JLabel();
		
//		GridLayout gridLayout = new GridLayout(1, 2);
//		this.setLayout(gridLayout);

		this.add(iconLabel);
//		this.add(titleLabel);
	}

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		iconLabel.setIcon(icon);
//		titleLabel.setText(value.toString());
		return this;
	}

}
